package initialize

import (
	"gin-bms/global"

	"github.com/go-redis/redis"
	"go.uber.org/zap"
)

func initRedis() {
	redisCfg := global.GLOBAL_CONFIG.Redis
	client := redis.NewClient(&redis.Options{
		Addr:     redisCfg.Addr,
		Password: redisCfg.Password,
		DB:       redisCfg.DB,
	})

	ping, err := client.Ping().Result()
	if err != nil {
		global.GLOBAL_LOG.Error("result connect ping failed,err:", zap.Any("err", err))
	} else {
		global.GLOBAL_LOG.Info("redis connect ping response:", zap.String("pong", ping))
		global.GLOBAL_REDIS = client
	}
}
